| Conditions | 1 |
| Paths | 1 |
| Total Lines | 32 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 0 |
| 1 | import { expect } from 'chai'; |
||
| 4 | describe('i18n.js', () => { |
||
| 5 | describe('Locale', () => { |
||
| 6 | it('should get locale from machine', () => { |
||
| 7 | return getLocale() |
||
| 8 | .then(locale => { |
||
| 9 | expect(locale).to.match(/^[a-z]{2}_([A-Z]{2,3})?$/); |
||
| 10 | }); |
||
| 11 | }); |
||
| 12 | |||
| 13 | it('should allow translation', () => { |
||
| 14 | const zh_CN = { |
||
| 15 | 'I\'m 20 years old': '我是18岁' |
||
| 16 | }; |
||
| 17 | const _ = translator(zh_CN); |
||
| 18 | |||
| 19 | expect(_('I\'m 20 years old')).to.equals('我是18岁'); |
||
| 20 | }); |
||
| 21 | |||
| 22 | it('should allow string interpolation', () => { |
||
| 23 | const zh_CN = { |
||
| 24 | '{{name}} is {{age}} years old': '{{name}}是{{age}}岁' |
||
| 25 | }; |
||
| 26 | const _ = translator(zh_CN); |
||
| 27 | const sentence = _('{{name}} is {{age}} years old', { |
||
| 28 | name: 'Celão', |
||
| 29 | age: 20 |
||
| 30 | }); |
||
| 31 | |||
| 32 | expect(sentence).to.equals('Celão是20岁'); |
||
| 33 | }); |
||
| 34 | }); |
||
| 35 | }); |
||
| 36 |